﻿using CinemaMaestro.BusinessLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CinemaMaestro.BusinessLayer
{
    public class BusinessObjectFactory : IBusinessObjectFactory
    {
        private IUnitOfWork _uow;

        public BusinessObjectFactory(IUnitOfWork uow)
        {
            _uow = uow;
        }

        private ILanguages _languages;
        public ILanguages Languages
        {
            get
            {
                if (_languages == null)
                {
                    _languages = new Languages(_uow);
                }

                return _languages;
            }
        }

        private IMovies _movies;
        public IMovies Movies
        {
            get
            {
                if (_movies == null)
                {
                    _movies = new Movies(_uow);
                }

                return _movies;
            }
        }

        private IActors _actors;
        public IActors Actors
        {
            get
            {
                if (_actors == null)
                {
                    _actors = new Actors(_uow);
                }

                return _actors;
            }
        }

        private ICategories _categories;
        public ICategories Categories
        {
            get
            {
                if (_categories == null)
                {
                    _categories = new Categories(_uow);
                }

                return _categories;
            }
        }

        private IDirectors _directors;
        public IDirectors Directors
        {
            get
            {
                if (_directors == null)
                {
                    _directors = new Directors(_uow);
                }

                return _directors;
            }
        }

        private ICinemas _cinemas;
        public ICinemas Cinemas
        {
            get
            {
                if (_cinemas == null)
                {
                    _cinemas = new Cinemas(_uow);
                }

                return _cinemas;
            }
        }

        private IRooms _rooms;
        public IRooms Rooms
        {
            get
            {
                if (_rooms == null)
                {
                    _rooms = new Rooms(_uow);
                }

                return _rooms;
            }
        }

        private IScreenings _screenings;
        public IScreenings Screenings
        {
            get
            {
                if (_screenings == null)
                {
                    _screenings = new Screenings(_uow);
                }

                return _screenings;
            }
        }

        private IReservations _reservations;
        public IReservations Reservations
        {
            get
            {
                if (_reservations == null)
                {
                    _reservations = new Reservations(_uow);
                }

                return _reservations;
            }
        }

        private ISales _sales;
        public ISales Sales
        {
            get
            {
                if (_sales == null)
                {
                    _sales = new Sales(_uow);
                }

                return _sales;
            }
        }

        public void SaveChanges()
        {
            _uow.SaveChanges();
        }
    }
}
